﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Power.Model;
using System.Data;
using System.Data.SqlClient;
using Power.DAL;

namespace Power
{
    /// <summary>
    /// ListTemp.xaml 的交互逻辑
    /// </summary>
    public partial class ListTemp : Window
    {
        public ListTemp()
        {
            InitializeComponent();
        }



        public string username
        {
            get;
            set;
        }

        public string device
        {
            get;
            set;
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {



            //List<Monitorc> list = new List<Monitorc>();
            //DataTable ds = SqlHelper.ExecuteDataTable("select * from T_test2 where Device=@Device", new SqlParameter("@Device", Tosearch.Text));
            //foreach (DataRow row in ds.Rows)
            //{


            //    Devices p = new Devices();
            //    p.DeviceID = (string)row["Device"];
            //    p.TempH = (string)row["TempH"];
            //    p.TempL = (string)row["TempL"];
            //    p.GPSJ = (string)row["GPSJ"];
            //    p.GPSW = (string)row["GPSW"];
            //    p.Time = Convert.ToString(row["Datetime"]);


            //    list.Add(p);
            //}
            //dg2.ItemsSource = list;






            List<ListTE> templist = new List<ListTE>();


            ListTE[] teall = new ListtempDAL().ToFind(device);

            foreach (ListTE teone in teall)
            {
                ListTE p = new ListTE();
                p.Device = device;
                p.Id = teone.Id;
                p.TempI = teone.TempI;
                p.TempO = teone.TempO;
                p.Dtime = teone.Dtime.ToString();
                p.GPSL = teone.GPSL;
                p.GPSW = teone.GPSW;
                templist.Add(p);

            }
            
            dg1.ItemsSource = templist;

















        }

        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {

            Scan scann = new Scan()                ;
            scann.device = device;
            
            scann.ShowDialog();

        }

        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            Locate newloc = new Locate();
            newloc.device = device;
            newloc.ShowDialog();
        }

        private void MenuItem_Click_3(object sender, RoutedEventArgs e)
        {
            Chart listchart = new Chart();
            listchart.device = device;
            listchart.ShowDialog();

        }
    }
}
